using System.ComponentModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;

namespace WPFTemplateLib.Attached.AttachGroup
{
	/// <summary>
	/// 带有头部的元素的附加属性管理类
	/// </summary>
	public static class HeaderedElement
    {
		#region 用于头部的附加属性

		//拷贝自 MahApps.Metro.Controls.HeaderedControlHelper

		#region [附加属性] 头部的前景画刷
		public static readonly DependencyProperty HeaderForegroundProperty
			= DependencyProperty.RegisterAttached("HeaderForeground", typeof(Brush), typeof(HeaderedElement), new UIPropertyMetadata(Brushes.White));
		/// <summary>
		/// Gets the value of the Foreground for the header.
		/// </summary>
		public static Brush GetHeaderForeground(UIElement element)
		{
			return (Brush)element.GetValue(HeaderForegroundProperty);
		}
		/// <summary>
		/// Sets the value of the Foreground for the header.
		/// </summary>
		public static void SetHeaderForeground(UIElement element, Brush value)
		{
			element.SetValue(HeaderForegroundProperty, value);
		}
		#endregion

		#region [附加属性] 头部的背景画刷
		public static readonly DependencyProperty HeaderBackgroundProperty
			= DependencyProperty.RegisterAttached("HeaderBackground", typeof(Brush), typeof(HeaderedElement),
				new UIPropertyMetadata(Panel.BackgroundProperty.DefaultMetadata.DefaultValue));
		/// <summary>
		/// Gets the value of the Background for the header.
		/// </summary>
		public static Brush GetHeaderBackground(UIElement element)
		{
			return (Brush)element.GetValue(HeaderBackgroundProperty);
		}
		/// <summary>
		/// Sets the value of the Background for the header.
		/// </summary>
		public static void SetHeaderBackground(UIElement element, Brush value)
		{
			element.SetValue(HeaderBackgroundProperty, value);
		}
		#endregion

		#region [附加属性] 头部的字体家族
		public static readonly DependencyProperty HeaderFontFamilyProperty
			= DependencyProperty.RegisterAttached("HeaderFontFamily", typeof(FontFamily), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontFamily, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontFamily for the header.
		/// </summary>
		public static FontFamily GetHeaderFontFamily(UIElement element)
		{
			return (FontFamily)element.GetValue(HeaderFontFamilyProperty);
		}
		/// <summary>
		/// Sets the value of the FontFamily for the header.
		/// </summary>
		public static void SetHeaderFontFamily(UIElement element, FontFamily value)
		{
			element.SetValue(HeaderFontFamilyProperty, value);
		}
		#endregion

		#region [附加属性] 头部的字号
		public static readonly DependencyProperty HeaderFontSizeProperty
			= DependencyProperty.RegisterAttached("HeaderFontSize", typeof(double), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontSize, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontSize for the header.
		/// </summary>
		public static double GetHeaderFontSize(UIElement element)
		{
			return (double)element.GetValue(HeaderFontSizeProperty);
		}
		/// <summary>
		/// Sets the value of the FontSize for the header.
		/// </summary>
		public static void SetHeaderFontSize(UIElement element, double value)
		{
			element.SetValue(HeaderFontSizeProperty, value);
		}
		#endregion

		#region [附加属性] 头部的字体伸缩
		public static readonly DependencyProperty HeaderFontStretchProperty
			= DependencyProperty.RegisterAttached("HeaderFontStretch", typeof(FontStretch), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(System.Windows.Documents.TextElement.FontStretchProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontStretch for the header.
		/// </summary>
		public static FontStretch GetHeaderFontStretch(UIElement element)
		{
			return (FontStretch)element.GetValue(HeaderFontStretchProperty);
		}
		/// <summary>
		/// Sets the value of the FontStretch for the header.
		/// </summary>
		public static void SetHeaderFontStretch(UIElement element, FontStretch value)
		{
			element.SetValue(HeaderFontStretchProperty, value);
		}
		#endregion

		#region [附加属性] 头部的字重
		public static readonly DependencyProperty HeaderFontWeightProperty
			= DependencyProperty.RegisterAttached("HeaderFontWeight", typeof(FontWeight), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontWeight, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontWeight for the header.
		/// </summary>
		public static FontWeight GetHeaderFontWeight(UIElement element)
		{
			return (FontWeight)element.GetValue(HeaderFontWeightProperty);
		}
		/// <summary>
		/// Sets the value of the FontWeight for the header.
		/// </summary>
		public static void SetHeaderFontWeight(UIElement element, FontWeight value)
		{
			element.SetValue(HeaderFontWeightProperty, value);
		}
		#endregion

		#region [附加属性] 头部的外边距
		public static readonly DependencyProperty HeaderMarginProperty
			= DependencyProperty.RegisterAttached("HeaderMargin", typeof(Thickness), typeof(HeaderedElement), new UIPropertyMetadata(new Thickness()));
		/// <summary>
		/// Gets or sets the outer margin for the header.
		/// </summary>
		public static Thickness GetHeaderMargin(UIElement element)
		{
			return (Thickness)element.GetValue(HeaderMarginProperty);
		}
		/// <summary>
		/// Sets or sets the outer margin for the header.
		/// </summary>
		public static void SetHeaderMargin(UIElement element, Thickness value)
		{
			element.SetValue(HeaderMarginProperty, value);
		}
		#endregion

		#region [附加属性] 头部的内边距
        public static Thickness GetHeaderPadding(DependencyObject obj)
		{
			return (Thickness)obj.GetValue(HeaderPaddingProperty);
		}
		/// <summary>
		/// 设置 头部的内边距
		/// </summary>
		public static void SetHeaderPadding(DependencyObject obj, Thickness value)
		{
			obj.SetValue(HeaderPaddingProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部的内边距
		/// </summary>
		public static readonly DependencyProperty HeaderPaddingProperty =
			DependencyProperty.RegisterAttached("HeaderPadding", typeof(Thickness), typeof(HeaderedElement), new PropertyMetadata(new Thickness(0)));
		#endregion

		#region [附加属性] 头部内容水平对齐方式
		public static readonly DependencyProperty HeaderHorizontalContentAlignmentProperty =
			DependencyProperty.RegisterAttached("HeaderHorizontalContentAlignment", typeof(HorizontalAlignment), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(HorizontalAlignment.Stretch));
		/// <summary>
		/// Gets the horizontal alignment of the header.
		/// </summary>
		public static HorizontalAlignment GetHeaderHorizontalContentAlignment(UIElement element)
		{
			return (HorizontalAlignment)element.GetValue(HeaderHorizontalContentAlignmentProperty);
		}
		/// <summary>
		/// Sets the horizontal alignment of the header.
		/// </summary>
		public static void SetHeaderHorizontalContentAlignment(UIElement element, HorizontalAlignment value)
		{
			element.SetValue(HeaderHorizontalContentAlignmentProperty, value);
		}
		#endregion

		#region [附加属性] 头部内容垂直对齐方式
		public static readonly DependencyProperty HeaderVerticalContentAlignmentProperty =
			DependencyProperty.RegisterAttached("HeaderVerticalContentAlignment", typeof(VerticalAlignment), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(VerticalAlignment.Stretch));
		/// <summary>
		/// Gets the vertical alignment of the header.
		/// </summary>
		public static VerticalAlignment GetHeaderVerticalContentAlignment(UIElement element)
		{
			return (VerticalAlignment)element.GetValue(HeaderVerticalContentAlignmentProperty);
		}
		/// <summary>
		/// Sets the vertical alignment of the header.
		/// </summary>
		public static void SetHeaderVerticalContentAlignment(UIElement element, VerticalAlignment value)
		{
			element.SetValue(HeaderVerticalContentAlignmentProperty, value);
		} 
		#endregion

		#region [附加属性] 头部的边框画刷
		public static Brush GetHeaderBorderBrush(DependencyObject obj)
		{
			return (Brush)obj.GetValue(HeaderBorderBrushProperty);
		}
		/// <summary>
		/// 设置 头部的边框画刷
		/// </summary>
		public static void SetHeaderBorderBrush(DependencyObject obj, Brush value)
		{
			obj.SetValue(HeaderBorderBrushProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部的边框画刷
		/// </summary>
		public static readonly DependencyProperty HeaderBorderBrushProperty =
			DependencyProperty.RegisterAttached("HeaderBorderBrush", typeof(Brush), typeof(HeaderedElement));
		#endregion

		#region [附加属性] 头部的边框粗细(默认0)
		public static Thickness GetHeaderBorderThickness(DependencyObject obj)
		{
			return (Thickness)obj.GetValue(HeaderBorderThicknessProperty);
		}
		/// <summary>
		/// 设置 头部的边框粗细(默认0)
		/// </summary>
		public static void SetHeaderBorderThickness(DependencyObject obj, Thickness value)
		{
			obj.SetValue(HeaderBorderThicknessProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部的边框粗细(默认0)
		/// </summary>
		public static readonly DependencyProperty HeaderBorderThicknessProperty =
			DependencyProperty.RegisterAttached("HeaderBorderThickness", typeof(Thickness), typeof(HeaderedElement), new PropertyMetadata(new Thickness(0)));
		#endregion

		#region [附加属性] 头部的圆角
		public static CornerRadius GetHeaderCornerRadius(DependencyObject obj)
		{
			return (CornerRadius)obj.GetValue(HeaderCornerRadiusProperty);
		}
		/// <summary>
		/// 设置 头部的圆角
		/// </summary>
		public static void SetHeaderCornerRadius(DependencyObject obj, CornerRadius value)
		{
			obj.SetValue(HeaderCornerRadiusProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部的圆角
		/// </summary>
		public static readonly DependencyProperty HeaderCornerRadiusProperty =
			DependencyProperty.RegisterAttached("HeaderCornerRadius", typeof(CornerRadius), typeof(HeaderedElement), new PropertyMetadata(new CornerRadius()));
		#endregion

		#region [附加属性] 头部宽度（默认 double.NaN）
		[TypeConverter(typeof(LengthConverter))]
		public static double GetHeaderWidth(DependencyObject obj)
		{
			return (double)obj.GetValue(HeaderWidthProperty);
		}
		/// <summary>
		/// 设置 头部宽度（默认 double.NaN）
		/// </summary>
		public static void SetHeaderWidth(DependencyObject obj, double value)
		{
			obj.SetValue(HeaderWidthProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部宽度（默认 double.NaN）
		/// </summary>
		public static readonly DependencyProperty HeaderWidthProperty =
			DependencyProperty.RegisterAttached("HeaderWidth", typeof(double), typeof(HeaderedElement), new PropertyMetadata(double.NaN));
		#endregion

		#region [附加属性] 头部高度（默认 double.NaN）
		[TypeConverter(typeof(LengthConverter))]
		public static double GetHeaderHeight(DependencyObject obj)
		{
			return (double)obj.GetValue(HeaderHeightProperty);
		}
		/// <summary>
		/// 设置 头部高度（默认 double.NaN）
		/// </summary>
		public static void SetHeaderHeight(DependencyObject obj, double value)
		{
			obj.SetValue(HeaderHeightProperty, value);
		}
		/// <summary>
		/// [附加属性] 头部高度（默认 double.NaN）
		/// </summary>
		public static readonly DependencyProperty HeaderHeightProperty =
			DependencyProperty.RegisterAttached("HeaderHeight", typeof(double), typeof(HeaderedElement), new PropertyMetadata(double.NaN));
		#endregion

		#endregion

		#region 用于内容的附加属性

		#region [附加属性] 内容的前景画刷
		public static readonly DependencyProperty ContentForegroundProperty
			= DependencyProperty.RegisterAttached("ContentForeground", typeof(Brush), typeof(HeaderedElement), new UIPropertyMetadata(Brushes.White));
		/// <summary>
		/// Gets the value of the Foreground for the Content.
		/// </summary>
		public static Brush GetContentForeground(UIElement element)
		{
			return (Brush)element.GetValue(ContentForegroundProperty);
		}
		/// <summary>
		/// Sets the value of the Foreground for the Content.
		/// </summary>
		public static void SetContentForeground(UIElement element, Brush value)
		{
			element.SetValue(ContentForegroundProperty, value);
		}
		#endregion

		#region [附加属性] 内容的背景画刷
		public static readonly DependencyProperty ContentBackgroundProperty
			= DependencyProperty.RegisterAttached("ContentBackground", typeof(Brush), typeof(HeaderedElement),
				new UIPropertyMetadata(Panel.BackgroundProperty.DefaultMetadata.DefaultValue));
		/// <summary>
		/// Gets the value of the Background for the Content.
		/// </summary>
		public static Brush GetContentBackground(UIElement element)
		{
			return (Brush)element.GetValue(ContentBackgroundProperty);
		}
		/// <summary>
		/// Sets the value of the Background for the Content.
		/// </summary>
		public static void SetContentBackground(UIElement element, Brush value)
		{
			element.SetValue(ContentBackgroundProperty, value);
		}
		#endregion

		#region [附加属性] 内容的字体家族
		public static readonly DependencyProperty ContentFontFamilyProperty
			= DependencyProperty.RegisterAttached("ContentFontFamily", typeof(FontFamily), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontFamily, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontFamily for the Content.
		/// </summary>
		public static FontFamily GetContentFontFamily(UIElement element)
		{
			return (FontFamily)element.GetValue(ContentFontFamilyProperty);
		}
		/// <summary>
		/// Sets the value of the FontFamily for the Content.
		/// </summary>
		public static void SetContentFontFamily(UIElement element, FontFamily value)
		{
			element.SetValue(ContentFontFamilyProperty, value);
		}
		#endregion

		#region [附加属性] 内容的字号
		public static readonly DependencyProperty ContentFontSizeProperty
			= DependencyProperty.RegisterAttached("ContentFontSize", typeof(double), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontSize, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontSize for the Content.
		/// </summary>
		public static double GetContentFontSize(UIElement element)
		{
			return (double)element.GetValue(ContentFontSizeProperty);
		}
		/// <summary>
		/// Sets the value of the FontSize for the Content.
		/// </summary>
		public static void SetContentFontSize(UIElement element, double value)
		{
			element.SetValue(ContentFontSizeProperty, value);
		}
		#endregion

		#region [附加属性] 内容的字体伸缩
		public static readonly DependencyProperty ContentFontStretchProperty
			= DependencyProperty.RegisterAttached("ContentFontStretch", typeof(FontStretch), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(System.Windows.Documents.TextElement.FontStretchProperty.DefaultMetadata.DefaultValue, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontStretch for the Content.
		/// </summary>
		public static FontStretch GetContentFontStretch(UIElement element)
		{
			return (FontStretch)element.GetValue(ContentFontStretchProperty);
		}
		/// <summary>
		/// Sets the value of the FontStretch for the Content.
		/// </summary>
		public static void SetContentFontStretch(UIElement element, FontStretch value)
		{
			element.SetValue(ContentFontStretchProperty, value);
		}
		#endregion

		#region [附加属性] 内容的字重
		public static readonly DependencyProperty ContentFontWeightProperty
			= DependencyProperty.RegisterAttached("ContentFontWeight", typeof(FontWeight), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(SystemFonts.MessageFontWeight, FrameworkPropertyMetadataOptions.Inherits));
		/// <summary>
		/// Gets the value of the FontWeight for the Content.
		/// </summary>
		public static FontWeight GetContentFontWeight(UIElement element)
		{
			return (FontWeight)element.GetValue(ContentFontWeightProperty);
		}
		/// <summary>
		/// Sets the value of the FontWeight for the Content.
		/// </summary>
		public static void SetContentFontWeight(UIElement element, FontWeight value)
		{
			element.SetValue(ContentFontWeightProperty, value);
		}
		#endregion

		#region [附加属性] 内容的外边距
		public static readonly DependencyProperty ContentMarginProperty
			= DependencyProperty.RegisterAttached("ContentMargin", typeof(Thickness), typeof(HeaderedElement), new UIPropertyMetadata(new Thickness()));
		/// <summary>
		/// Gets or sets the outer margin for the Content.
		/// </summary>
		public static Thickness GetContentMargin(UIElement element)
		{
			return (Thickness)element.GetValue(ContentMarginProperty);
		}
		/// <summary>
		/// Sets or sets the outer margin for the Content.
		/// </summary>
		public static void SetContentMargin(UIElement element, Thickness value)
		{
			element.SetValue(ContentMarginProperty, value);
		}
		#endregion

		#region [附加属性] 内容的内边距
		public static Thickness GetContentPadding(DependencyObject obj)
		{
			return (Thickness)obj.GetValue(ContentPaddingProperty);
		}
		/// <summary>
		/// 设置 内容的内边距
		/// </summary>
		public static void SetContentPadding(DependencyObject obj, Thickness value)
		{
			obj.SetValue(ContentPaddingProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容的内边距
		/// </summary>
		public static readonly DependencyProperty ContentPaddingProperty =
			DependencyProperty.RegisterAttached("ContentPadding", typeof(Thickness), typeof(HeaderedElement), new PropertyMetadata(new Thickness(0)));
		#endregion

		#region [附加属性] 内容区域的内容水平对齐方式
		public static readonly DependencyProperty ContentHorizontalContentAlignmentProperty =
			DependencyProperty.RegisterAttached("ContentHorizontalContentAlignment", typeof(HorizontalAlignment), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(HorizontalAlignment.Stretch));
		/// <summary>
		/// Gets the horizontal alignment of the Content.
		/// </summary>
		public static HorizontalAlignment GetContentHorizontalContentAlignment(UIElement element)
		{
			return (HorizontalAlignment)element.GetValue(ContentHorizontalContentAlignmentProperty);
		}
		/// <summary>
		/// Sets the horizontal alignment of the Content.
		/// </summary>
		public static void SetContentHorizontalContentAlignment(UIElement element, HorizontalAlignment value)
		{
			element.SetValue(ContentHorizontalContentAlignmentProperty, value);
		}
		#endregion

		#region [附加属性] 内容区域的内容垂直对齐方式
		public static readonly DependencyProperty ContentVerticalContentAlignmentProperty =
			DependencyProperty.RegisterAttached("ContentVerticalContentAlignment", typeof(VerticalAlignment), typeof(HeaderedElement),
				new FrameworkPropertyMetadata(VerticalAlignment.Stretch));
		/// <summary>
		/// Gets the vertical alignment of the Content.
		/// </summary>
		public static VerticalAlignment GetContentVerticalContentAlignment(UIElement element)
		{
			return (VerticalAlignment)element.GetValue(ContentVerticalContentAlignmentProperty);
		}
		/// <summary>
		/// Sets the vertical alignment of the Content.
		/// </summary>
		public static void SetContentVerticalContentAlignment(UIElement element, VerticalAlignment value)
		{
			element.SetValue(ContentVerticalContentAlignmentProperty, value);
		} 
		#endregion

		#region [附加属性] 内容的边框画刷
		public static Brush GetContentBorderBrush(DependencyObject obj)
		{
			return (Brush)obj.GetValue(ContentBorderBrushProperty);
		}
		/// <summary>
		/// 设置 内容的边框画刷
		/// </summary>
		public static void SetContentBorderBrush(DependencyObject obj, Brush value)
		{
			obj.SetValue(ContentBorderBrushProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容的边框画刷
		/// </summary>
		public static readonly DependencyProperty ContentBorderBrushProperty =
			DependencyProperty.RegisterAttached("ContentBorderBrush", typeof(Brush), typeof(HeaderedElement));
		#endregion

		#region [附加属性] 内容的边框粗细(默认0)
		public static Thickness GetContentBorderThickness(DependencyObject obj)
		{
			return (Thickness)obj.GetValue(ContentBorderThicknessProperty);
		}
		/// <summary>
		/// 设置 内容的边框粗细(默认0)
		/// </summary>
		public static void SetContentBorderThickness(DependencyObject obj, Thickness value)
		{
			obj.SetValue(ContentBorderThicknessProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容的边框粗细(默认0)
		/// </summary>
		public static readonly DependencyProperty ContentBorderThicknessProperty =
			DependencyProperty.RegisterAttached("ContentBorderThickness", typeof(Thickness), typeof(HeaderedElement), new PropertyMetadata(new Thickness(0)));
		#endregion

		#region [附加属性] 内容的圆角
		public static CornerRadius GetContentCornerRadius(DependencyObject obj)
		{
			return (CornerRadius)obj.GetValue(ContentCornerRadiusProperty);
		}
		/// <summary>
		/// 设置 内容的圆角
		/// </summary>
		public static void SetContentCornerRadius(DependencyObject obj, CornerRadius value)
		{
			obj.SetValue(ContentCornerRadiusProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容的圆角
		/// </summary>
		public static readonly DependencyProperty ContentCornerRadiusProperty =
			DependencyProperty.RegisterAttached("ContentCornerRadius", typeof(CornerRadius), typeof(HeaderedElement), new PropertyMetadata(new CornerRadius()));
		#endregion

		#region [附加属性] 内容宽度（默认 double.NaN）
		[TypeConverter(typeof(LengthConverter))]
		public static double GetContentWidth(DependencyObject obj)
		{
			return (double)obj.GetValue(ContentWidthProperty);
		}
		/// <summary>
		/// 设置 内容宽度（默认 double.NaN）
		/// </summary>
		public static void SetContentWidth(DependencyObject obj, double value)
		{
			obj.SetValue(ContentWidthProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容宽度（默认 double.NaN）
		/// </summary>
		public static readonly DependencyProperty ContentWidthProperty =
			DependencyProperty.RegisterAttached("ContentWidth", typeof(double), typeof(HeaderedElement), new PropertyMetadata(double.NaN));
		#endregion

		#region [附加属性] 内容高度（默认 double.NaN）
		[TypeConverter(typeof(LengthConverter))]
		public static double GetContentHeight(DependencyObject obj)
		{
			return (double)obj.GetValue(ContentHeightProperty);
		}
		/// <summary>
		/// 设置 内容高度（默认 double.NaN）
		/// </summary>
		public static void SetContentHeight(DependencyObject obj, double value)
		{
			obj.SetValue(ContentHeightProperty, value);
		}
		/// <summary>
		/// [附加属性] 内容高度（默认 double.NaN）
		/// </summary>
		public static readonly DependencyProperty ContentHeightProperty =
			DependencyProperty.RegisterAttached("ContentHeight", typeof(double), typeof(HeaderedElement), new PropertyMetadata(double.NaN));
		#endregion

		#endregion
	}
}
